﻿package app.model 
{
	import app.ApplicationFacade;
	import flash.display.DisplayObject;
	import flash.display.Stage;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.utils.setTimeout;
	import org.puremvc.interfaces.IProxy;
	import org.puremvc.patterns.proxy.Proxy;
	
	/**
	 * ...
	 * @author dmitryi
	 */
	public class StageProxy extends Proxy implements IProxy
	{
		public static const NAME:String = "StageProxy";
		private var _stage:Stage;
		
		public function StageProxy(st:Stage) 
		{
			super(NAME, null);
			_stage = st;
			
			setStage();
			
			_stage.addEventListener(Event.RESIZE, onResize);
			
			update(100);
		}
		
		public function update(delay:Number=0):void
		{
			setTimeout(onResize, delay);
		}
		
		private function setStage():void
		{
			_stage.scaleMode = StageScaleMode.NO_SCALE;
			_stage.align = StageAlign.TOP_LEFT;
			_stage.showDefaultContextMenu = false;
		}
		
		private function onResize(e:Event=null):void 
		{
			////trace('onResize');
			sendNotification(ApplicationFacade.STAGE_RESIZE, _stage);
			
		}
		
	}

}